package com.ruoyi.rsikManage.mapper;

import com.ruoyi.rsikManage.domain.AlarmEvent;
import com.ruoyi.rsikManage.domain.PlaceCategory;
import com.ruoyi.rsikManage.domain.TAlarms;
import com.ruoyi.rsikManage.domain.vo.AlarmOfEachDayVo;
import com.ruoyi.rsikManage.domain.vo.AlarmOfEachLevelVo;
import com.ruoyi.rsikManage.domain.vo.HistogramVo;
import com.ruoyi.rsikManage.domain.vo.RealTimeAlarmCountVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 报警信息Mapper接口
 *
 * @author ruoyi
 * @date 2023-08-08
 */
@Mapper
public interface TAlarmsMapper
{
    int countAiAlarm(@Param("placeId") Long placeId, @Param("alarmType") String alarmType, @Param("year") Integer year, @Param("month") Integer month, @Param("day") Integer day);
    int countUnhandledAiAlarmInProvinceFileForToday(String placeCategoryDicVal);
    int countHandlingAiAlarmInProvinceFileForToday(String placeCategoryDicVal);
    int countHandledAiAlarmInProvinceFileForToday(String placeCategoryDicVal);
    int countAllAiAlarmInProvinceFileForToday(String placeCategoryDicVal);
    int insertGroundAlarmSituationOfCurrent(@Param("unhandledAlarmCount") int unhandledAlarmCount, @Param("handledAlarmCount") int handledAlarmCount, @Param("alarmCount") int alarmCount,@Param("isThereUnhandledAlarm") int isThereUnhandledAlarm);
    int insertUndergroundKeyPositionsAlarmSituationOfCurrent(@Param("unhandledAlarmCount") int unhandledAlarmCount, @Param("handledAlarmCount") int handledAlarmCount, @Param("alarmCount") int alarmCount, @Param("isThereUnhandledAlarm") int isThereUnhandledAlarm);
    int insertKeyMinesUndergroundAlarmSituationOfCurrent(@Param("unhandledAlarmCount") int unhandledAlarmCount, @Param("handledAlarmCount") int handledAlarmCount, @Param("alarmCount") int alarmCount, @Param("isThereUnhandledAlarm") int isThereUnhandledAlarm);
    List<AlarmEvent> selectAlarmEventList(AlarmEvent alarmEvent);
    int markAlarmEventAsSent(List<AlarmEvent> alarmEvents);

    //只查询今当天的报警数
    Integer countTAlarmsInThisMonitor(@Param("apeId") String apeId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
    /**
     * 查询报警信息
     *
     * @param idId 报警信息ID
     * @return 报警信息
     */
    public TAlarms selectTAlarmsById(Long idId);

    /**
     * 查询报警信息列表
     *
     * @param tAlarms 报警信息
     * @return 报警信息集合
     */
    public List<TAlarms> selectTAlarmsList(TAlarms tAlarms);

    /**
     * 新增报警信息
     *
     * @param tAlarms 报警信息
     * @return 结果
     */
    public int insertTAlarms(TAlarms tAlarms);

    /**
     * 修改报警信息
     *
     * @param tAlarms 报警信息
     * @return 结果
     */
    public int updateTAlarms(TAlarms tAlarms);

    /**
     * 删除报警信息
     *
     * @param idId 报警信息ID
     * @return 结果
     */
    public int deleteTAlarmsById(Long idId);

    /**
     * 批量删除报警信息
     *
     * @param idIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteTAlarmsByIds(Long[] idIds);

    List<HistogramVo> countAlgoAlarmForEachType(@Param("startTime")Date startTime,
                                                @Param("endTime") Date endTime);

    int countAlgoAlarmInDate(@Param("year") Integer year,
                             @Param("month") Integer month,
                             @Param("alarmName") String alarmName);

    int countAlgoAlarmInDateForUnitCodes(@Param("year") Integer year,
                                         @Param("month") Integer month,
                                         @Param("alarmName") String alarmName,
                                         @Param("unitCodes") List<Long> unitCodes);


    List<HistogramVo> countOfflineForEachMonitor(@Param("startTime") Date startTime,
                                                 @Param("endTime")  Date endTime);

    List<HistogramVo> countOfflineForEachMonitorForUnitCodes(@Param("startTime") LocalDateTime startTime,
                                                             @Param("endTime")  LocalDateTime endTime,
                                                             @Param("unitCodes") List<Long> unitCodes);

    int countOfflineInDate(@Param("year") Integer year,
                           @Param("month") Integer month);


    int countOfflineInDateForUnitCodes(@Param("year") Integer year,
                                       @Param("month") Integer month,
                                       @Param("unitCodes") List<Long> unitCodes);

    List<HistogramVo> countDiagnosisAbnorForEachMonitor(@Param("startTime") Date startTime,
                                                        @Param("endTime")  Date endTime);

    List<HistogramVo> countDiagnosisAbnorForEachMonitorForUnitCodes(@Param("startTime") LocalDateTime startTime,
                                                                    @Param("endTime")  LocalDateTime endTime,
                                                                    @Param("unitCodes") List<Long> unitCodes);


    int countDiagnosisAlarmInDate(@Param("year") Integer year, @Param("month") Integer month);

    int countDiagnosisAlarmInDateForUnitCodes(@Param("year") Integer year,
                                              @Param("month") Integer month,
                                              @Param("unitCodes") List<Long> unitCodes);


    int countOffline(@Param("monitorId") String monitorId,
                     @Param("startTime")Date startTime,
                     @Param("endTime") Date endTime);

    int countDiagnosisAbnor(@Param("monitorId")String monitorId,
                            @Param("startTime")Date startTime,
                            @Param("endTime") Date endTime);

    int countAlarmOfAlarmLevel(String alarmLevelDictVal);

    List<Map<String,Object>> countAlarmType(@Param("startTime")Date startTime,
                                            @Param("endTime") Date endTime);

    List<Map<String,Object>> countAlarmTypeForUnitCodes(@Param("startTime")LocalDateTime startTime,
                                              @Param("endTime") LocalDateTime endTime,
                                              @Param("unitCodes")List<Long> unitCodes);


    List<RealTimeAlarmCountVo> selectGroundAlarmSituation();

    List<RealTimeAlarmCountVo> selectUndergroundKeyPositionsAlarmSituation();

    List<RealTimeAlarmCountVo> selectKeyMinesUndergroundAlarmSituation();

    String selectTheURLWhereTheAlarmInfoIsSentTo();

    int setTheURLWhereTheAlarmInfoIsSentTo(String url);

    List<PlaceCategory> countAlarmOfCategoryAndPlace(@Param("startTime") Date startTime,
                                                     @Param("endTime") Date endTime);

    List<PlaceCategory> countAlarmOfCategoryAndPlaceForUnitCodes(@Param("startTime") LocalDateTime startTime,
                                                                 @Param("endTime") LocalDateTime endTime,
                                                                 @Param("unitCodes")List<Long> unitCodes);


    List<AlarmOfEachDayVo> countAlarmOfEachDay(@Param("startTime") Date startTime,
                                               @Param("endTime") Date endTime,
                                               @Param("alarmName") String alarmName);

    List<AlarmOfEachDayVo> countAlarmOfEachDayForUnitCodes(@Param("startTime") LocalDateTime startTime,
                                                 @Param("endTime") LocalDateTime endTime,
                                                 @Param("alarmName") String alarmName,
                                                 @Param("unitCodes")List<Long> unitCodes);

    List<AlarmOfEachLevelVo> countAlarmOfEachLevel(@Param("startTime") Date startTime,
                                                   @Param("endTime") Date endTime);
}
